<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>会员注册</title>
    <link rel="stylesheet" type="text/css" href="__STATIC__/yt_css/initialize.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/yt_css/ipad.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/yt_css/iPhone.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/yt_css/style.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/yt_css/swiper.css" />
	<script type="text/javascript" src="__STATIC__/yt_js/jquery-1.9.0.min.js"></script>
	<script src="__PUBLIC__/static/js/layer/layer.js" type="text/javascript"></script>
</head>
<body class="body1">
<div class="container">
	<include file="user/new_header"/>
			<div class="register">
				<form id="reg_form2"  method="post" action="">
					<div class="zong">
						<div class="bor">
							<input class="username" type="text"  placeholder="手机号码"  name="username" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" id="username" autocomplete="off" value="">
						</div>
						<div class="bor" >
							<input class="verify" type="text"  placeholder="验证码" id="verify_code" name="verify_code" autocomplete="off" value="">
							<div class="yzm">
								<img width="160" height="50" src="/index.php/Home/User/verify/type/user_reg.html" id="reflsh_code2" onclick="verify('reflsh_code2')" class="po-ab to0">
							</div>
						</div>
                        <if condition="$regis_smtp_enable eq 1">
                        <div class="bor">
                            <input class="m_verify"  type="text" autocomplete="off" placeholder="请输入验证码">
                            <button type="button" id="sendCode" onclick="send_sms_reg_code()" class="yz">发送</button>
                        </div>
                        </if>
						<div class="bor">
							<input class="password" type="password" placeholder="密码"  autocomplete="off" placeholder="6-16位大小写英文字母、数字或符号的组合" maxlength="16"  id="password" name="password"  value="">
						</div>
						<div class="bor">
							<input class="password2" type="password" placeholder="确认密码"  placeholder="请再次输入密码" autocomplete="off" maxlength="16" id="password2" name="password2"  value="">
						</div>
					</div>
                </form>
					<div class="btn">
						<button onClick="check_submit();">注册</button>
						<a style="text-align: center; margin-top: 10px" href="{:U('Home/User/login')}">已有账号，<span style="color: #FF4466">去登录</span></a>
					</div>
			</div>
			<include file="public/new_footer"/>
		</div>

		<script type="text/javascript">
			// 普通 图形验证码
			function verify(id){
				$('#'+id).attr('src','/index.php?m=Home&c=User&a=verify&type=user_reg&r='+Math.random());
			}
			function check_submit(){
				$.ajax({
					type : "POST",
					url:"{:U('Home/User/reg')}",
					dataType: "json",
					data: $('#reg_form2').serialize(),
					success: function(data){
						if(data.status == 1){
							layer.msg(data.msg, {icon: 1},function(){
								window.location.href = "{:U('Home/Index/index')}";
							});
						}else{
							layer.alert(data.msg, {icon: 2},function(index){
								$('.verifyImg').trigger('click');
								layer.close(index);
							});
						}
					}
				});

			}

			// 发送手机短信
			function send_sms_reg_code(){
				var mobile = $('input[name="username"]').val();
				var verify_code = $('input[name="verify_code"]').val();
				if(!checkMobile(mobile)){
					layer.alert('请输入正确的手机号码', {icon: 2});//alert('请输入正确的手机号码');
					return;
				}
				if(verify_code == ''){
					layer.alert('请输入图像验证码', {icon: 2});//alert('请输入正确的手机号码');
					return;
				}
				var url = "/index.php?m=Home&c=Api&a=send_validate_code&scene=1&type=mobile&mobile="+mobile+"&verify_code="+verify_code;
				$.ajax({
					url:url,
					dataType: "json",
					success: function(res){
						if(res.status == 1)
						{
							$('#count_down').attr("disabled","disabled");
							intAs = 10; // 手机短信超时时间
							jsInnerTimeout('count_down',intAs);
							layer.alert(res.msg, {icon: 1});
						}else{
							layer.alert(res.msg, {icon: 2});
							verify('reflsh_code2')
						}
					}
				});
			}

			// 发送邮箱
			function send_smtp_reg_code(){
				var email = $('input[name="username"]').val();
				var verify_code = $('input[name="verify_code"]').val();
				if(!checkEmail(email)){
					layer.alert('请输入正确的邮箱', {icon: 2});//alert('请输入正确的手机号码');
					return;
				}
				if(verify_code == ''){
					layer.alert('请输入图像验证码', {icon: 2});//alert('请输入正确的手机号码');
					return;
				}
				$.ajax({
					type : "POST",
					url:"{:U('Home/Api/send_validate_code')}",
					data : {type:'email',send:email,scene:1,verify_code:verify_code},// 你的formid
					dataType: "json",
					success: function(data){
						if(data.status == 1){
							$('#count_down').attr("disabled","disabled");
							intAs = 10; // 发送邮箱超时时间
							jsInnerTimeout('count_down',intAs);
							layer.alert(data.msg, {icon: 1});
						}else{
							layer.alert(data.msg, {icon: 2});
							verify('reflsh_code2')
						}
					}
				});
			}

			$('#count_down').removeAttr("disabled");
			//倒计时函数
			function jsInnerTimeout(id,intAs)
			{
				var codeObj=$("#"+id);
				//var intAs = parseInt(codeObj.attr("IntervalTime"));

				intAs--;
				if(intAs<=-1)
				{
					codeObj.removeAttr("disabled");
//            codeObj.attr("IntervalTime",60);
					codeObj.text("发送");
					return true;
				}

				codeObj.text(intAs+'秒');
//        codeObj.attr("IntervalTime",intAs);

				setTimeout("jsInnerTimeout('"+id+"',"+intAs+")",1000);
			};


			function checkMobile(tel) {
				var reg = /(^1[3|4|5|7|8][0-9]{9}$)/;
				if (reg.test(tel)) {
					return true;
				}else{
					return false;
				};
			}

			function checkEmail(str){
				var reg = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
				if(reg.test(str)){
					return true;
				}else{
					return false;
				}
			}
            $(document).ready(function () {
                var height = $(window).height()-480;
                $('.register').css('min-height',height)
            })
		</script>
	</body>

</html>